package MathTest;

public class NarcissisticNumber {
    public static void main(String[] args) {
        getNarcNum();
        System.out.println("---------------------------------------------------");
        getFourLeafRosesNum();
        System.out.println("---------------------------------------------------");
        getFivePointedStar();
    }

    private static void getNarcNum() {
        int temp=0;
        for (int i = 100; i < 1000; i++) {
            if (Math.pow(i/100%10,3)+Math.pow(i/10%10,3)+Math.pow(i/1%10,3)==i){
                System.out.println(i);
                temp++;
            }
        }
        System.out.println(temp);
    }

    private static void getFourLeafRosesNum(){
        int temp=0;
        for (int i = 1000; i < 10000; i++) {
            if (Math.pow(i/1000%10,4)+Math.pow(i/100%10,4)+Math.pow(i/10%10,4)+Math.pow(i/1%10,4)==i){
                System.out.println(i);
                temp++;
            }
        }
        System.out.println(temp);
    }

    private static void getFivePointedStar(){
        int temp=0;
        for (int i = 1000; i < 10000; i++) {
            if (Math.pow(i/10000%10,5)+Math.pow(i/1000%10,5)+Math.pow(i/100%10,5)+Math.pow(i/10%10,5)+Math.pow(i/1%10,5)==i){
                System.out.println(i);
                temp++;
            }
        }
        System.out.println(temp);
    }
}
